import java.util.Scanner;

/**
 * Created with IDEA
 * author:ju bai
 * Date:2021/4/12
 * Time:19:39
 **/
public class Main1 {
    /**
     * 每日一题-排序子序列
     * 100%
     *
     * @param args
     */
    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            scanner.nextLine();
            int[] array = new int[n];
            for (int i = 0; i < n; i++) {
                array[i] = scanner.nextInt();
            }

            int flag = 0;//用一个标志来判断递增、递减、不变
            int count = 1;//表示分的段数
            for (int i = 1; i < n; i++) {
                if (array[i] > array[i - 1]) {//递增
                    if (flag == 0) {
                        flag = 1;
                    }
                    if (flag == -1) {
                        flag = 0;
                        count++;//表示增变减，得分段了
                    }
                } else if (array[i] < array[i - 1]) {//递减
                    if (flag == 0) {
                        flag = -1;
                    }
                    if (flag == 1) {//减变增
                        flag = 0;
                        count++;
                    }
                }
            }
            System.out.println(count);
        }
        scanner.close();
    }

    /**
     * 1 2 3 4 5 递增 (a[i]<a[i+1])
     * 5 4 3 2 1 递减 (a[i]>a[i+1])
     * 1 2 3 3 4 5 6 6 非递减 (a[i]<=a[i+1])
     * 9 8 7 7 6 5 3 1 非递增 (a[i]>=a[i+1])
     * @param args
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int n = sc.nextInt();
            int[] array = new int[n + 1];
            for (int i = 0; i < n; i++) {
                array[i] = sc.nextInt();
            }
            int i = 0;
            int count = 0;
            while (i < n) {
                if (array[i] < array[i + 1]) {
                    while (array[i] < array[i + 1] && i < n) {
                        i++;
                    }
                    count++;
                    i++;
                } else if (array[i] == array[i + 1]) {
                    i++;
                } else {
                    while (i < n && array[i] > array[i + 1]) {
                        i++;
                    }
                    count++;
                    i++;
                }
            }
            System.out.println(count);
        }
    }
}
